

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>
<head>
<script type="text/javascript" src="helpman_topicinit.js"></script>

<title>Language Macros [Enterprise Architect User Guide]</title>

<meta name="keywords" content="Enterprise Architect, Sparx Systems, UML, Language,Language Macros,Macro,Macro Language,Macro Preprocessor,Preprocessor Macros">
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<meta http-equiv="Content-Style-Type" content="text/css" />

<link type="text/css" href="default.css" rel="stylesheet" />
<style type="text/css">
  A, A:Visited
  {
    color: #00F;
  }

  A:Active, A:Hover
  {
    color: #F00;
  }

  OL
  {
    margin: 5px 0 5px 48px;
  }

  UL
  {
    margin-bottom: 3px;
    margin-top: 0;
  }

  #nsr
  {
    background-color: #D4DFFF;
  }

  #nsr A
  {
    text-decoration: none;
  }

  #mainbody
  {
    padding: 8px;
  }

  .p_BodyText
  {
    padding: 5px 0;
  }
</style>



<style type="text/css" media="screen">
  BODY
  {
    background-color: #FFFFFF;
  }

  #nsr
  {
    padding: 6px 6px 0 6px;
    border-bottom: none;
    vertical-align: top;
    z-index: 2;
    visibility: visible;
    left: 0;
    top: 0;
    position: absolute;
  }

  #mainbody
  {
    left: 0;
    top: 0;
    margin: 0;
    position: absolute;
    padding: 10px;
    overflow: auto;
    height: 100%;
    z-index: 1;
    background-repeat: no-repeat;
    background-position: bottom right;
    background-attachment: fixed;
  }
</style>

<style type="text/css" media="print">
  #nsr
  {
    visibility: none;
  }

  #mainbody
  {
    overflow: visible;
  }
</style>
<script type="text/javascript" language="JavaScript" src="nonscroll.js"></script>

</head>
<body scroll="no">

<div id="page">



        <div id="content">
          <div id="content-inner">
          



  
          <div id="nsr">
            <table border="0" cellspacing="0" cellpadding="4" width="100%">
              <tr valign="top">
                <td align="left">
  


                  <p class="p_Heading1"><span class="f_Heading1">Language Macros</span></p>



  
                </td>
                <td align="right">
                  <a href="introduction.htm" onmouseover="document.images.main.src='button_main_h.gif'" onmouseout="document.images.main.src='button_main.gif'">
                    <img name="main" src="button_main.gif" border=0 alt="Return to Introduction">
                  </a>&nbsp;
    
                  <a href="localpathdlg.htm" onmouseover="document.images.prev.src='button_prev_h.gif'" onmouseout="document.images.prev.src='button_prev.gif'">
                    <img name=prev src="button_prev.gif" border=0 alt="Previous page" />
                  </a>&nbsp;
    
    
    
                  <a href="settingcollectionclasses.htm" onmouseover="document.images.next.src='button_next_h.gif'" onmouseout="document.images.next.src='button_next.gif'">
                    <img name=next src="button_next.gif" border=0 alt="Next page" />
                  </a>
    
    
                </td>
              </tr>
            </table>
          </div>
          <div id="mainbody">
  


                <p class="p_BodyText"><span class="f_BodyText">When reverse engineering a language such as C++, you might find preprocessor directives scattered throughout the code. This can make code management easier, but can hamper parsing of the underlying C++ language.</span></p>
<p class="p_BodyText"><span class="f_BodyText">To help remedy this, you can include any number of </span><span class="f_BodyText" style="font-style: italic;">macro</span><span class="f_BodyText"> definitions, which are ignored during the parsing phase of the reverse engineering. It is still preferable, if you have the facility, to preprocess the code using the appropriate compiler first; this way, complex macro definitions and defines are expanded out and can be readily parsed. If you don't have this facility, then this option provides a convenient substitute.</span></p>
<div style="text-align: left; text-indent: 0px; padding: 0px 0px 0px 0px; margin: 5px 0px 5px 13px;"><table cellspacing="0" cellpadding="2" border="0" style="border: none; border-spacing:0px;">
<tr style="text-align:left;vertical-align:bottom;">
<td valign="bottom" width="952" bgcolor="#efeff7" style="width:952px; background-color:#efeff7;"><p class="p_TiporNote" style="border-top: none; border-right: none; border-left: none;"><span class="f_TiporNote">Note:</span></p>
</td>
</tr>
<tr style="text-align:left;">
<td width="952" bgcolor="#f7f7ff" style="width:952px; background-color:#f7f7ff;"><p class="p_TiporNoteText"><span class="f_TiporNoteText">You can transport these language macro (or preprocessor macro) definitions between models, using the </span><span class="f_MenuKeyField"><a href="exportrefdata.htm">Export Reference Data</a></span><span class="f_TiporNoteText"> and </span><span class="f_MenuKeyField"><a href="importrefdata.htm">Import Reference Data</a></span><span class="f_TiporNoteText"> options on the </span><span class="f_MenuKeyField">Tools</span><span class="f_TiporNoteText"> menu. The macros are exported as a </span><span class="f_TiporNoteText" style="font-style: italic;">Macro List</span><span class="f_TiporNoteText">.</span></p>
</td>
</tr>
</table>
</div>
<p class="p_SubHeadingL1"><span class="f_SubHeadingL1">Define a Macro</span></p>
<ol style="text-indent: 0px; margin-left: 48px; list-style-position: outside;">
<li value=1><span class="f_NumberedList">Select the </span><span class="f_MenuKeyField">Settings | Preprocessor Macros</span><span class="f_NumberedList"> menu option. The </span><span class="f_UIControl">Language Macros</span><span class="f_NumberedList"> dialog displays.</span><br>
<span class="f_NumberedList">&nbsp;</span><br>
<img src="languagemacros.png" width="318" height="255" border="0" alt="LanguageMacros"><br>
<span class="f_NumberedList">&nbsp;</span></li>
<li value=2><span class="f_NumberedList">Click on the</span><span class="f_MenuKeyField"> Add New</span><span class="f_NumberedList"> button.</span></li>
<li value=3><span class="f_NumberedList">Enter details for your macro.</span></li>
<li value=4><span class="f_NumberedList">Click on the </span><span class="f_MenuKeyField">OK</span><span class="f_NumberedList"> button.</span></li>
</ol>
<p class="p_SubHeadingL1"><span class="f_SubHeadingL1">Macros Embedded Within Declarations</span></p>
<p class="p_BodyText"><span class="f_BodyText">Macros are sometimes used within the declaration of Classes and operations, as in the following examples:</span></p>
<p class="p_Code"><span class="f_Code">class __declspec Foo</span></p>
<p class="p_Code"><span class="f_Code">{</span></p>
<p class="p_Code"> &nbsp; &nbsp; &nbsp; &nbsp;<span class="f_Code">int __declspec Bar(int p);</span></p>
<p class="p_Code"><span class="f_Code">};</span></p>
<p class="p_BodyText"><span class="f_BodyText">If </span><span class="f_BodyText" style="font-style: italic;">declspec</span><span class="f_BodyText"> is defined as a C++ macro, as outlined above, the imported Class and operation contain a Tagged Value called </span><span class="f_BodyText" style="font-style: italic;">DeclMacro1</span><span class="f_BodyText"> with value </span><span class="f_BodyText" style="font-style: italic;">__declspec</span><span class="f_BodyText">. (Subsequent macros would be defined as </span><span class="f_BodyText" style="font-style: italic;">DeclMacro2</span><span class="f_BodyText">, </span><span class="f_BodyText" style="font-style: italic;">DeclMacro3</span><span class="f_BodyText"> and so on.) During forward engineering, these Tagged Values are used to regenerate the macros in code.</span></p>
<p class="p_SubHeadingL1"><span class="f_SubHeadingL1">Define Complex Macros</span></p>
<p class="p_BodyText"><span class="f_BodyText">It is sometimes useful to define rules for complex macros that can span multiple lines. Enterprise Architect ignores the entire code section defined by the rule. Such macros can be defined in Enterprise Architect as in the following two examples. Both types can be combined in one definition.</span></p>
<p class="p_BodyText"><span class="f_BodyText" style="font-style: italic; font-weight: bold;">Block Macros</span></p>
<p class="p_Code"><span class="f_Code">BEGIN_INTERFACE_PART ^ END_INTERFACE_PART</span></p>
<p class="p_BodyText"><span class="f_BodyText">where the </span><span class="f_BodyText" style="font-style: italic; font-weight: bold;">^</span><span class="f_BodyText"> symbol represents the body of the macro. This enables skipping from one macro to another.</span></p>
<div style="text-align: left; text-indent: 0px; padding: 0px 0px 0px 0px; margin: 5px 0px 5px 13px;"><table cellspacing="0" cellpadding="2" border="0" style="border: none; border-spacing:0px;">
<tr style="text-align:left;vertical-align:bottom;">
<td valign="bottom" width="952" bgcolor="#efeff7" style="width:952px; background-color:#efeff7;"><p class="p_TiporNote" style="border-top: none; border-right: none; border-left: none;"><span class="f_TiporNote">Note:</span></p>
</td>
</tr>
<tr style="text-align:left;">
<td width="952" bgcolor="#f7f7ff" style="width:952px; background-color:#f7f7ff;"><p class="p_TiporNoteText"><span class="f_TiporNoteText">The spaces surrounding the </span><span class="f_TiporNoteText">^</span><span class="f_TiporNoteText"> symbol are required.</span></p>
</td>
</tr>
</table>
</div>
<p class="p_BodyText"><span class="f_BodyText" style="font-style: italic; font-weight: bold;">Function Macros</span></p>
<p class="p_Code"><span class="f_Code">RTTI_EMULATION()</span></p>
<p class="p_BodyText"><span class="f_BodyText">where Enterprise Architect skips over the token including everything inside the parentheses.</span></p>




            </div>
          </div>
        </div>



</div>


</body>
</html>
